package com.jiangjiang.eshop.order.price.v1.calculator;

import com.alibaba.fastjson.JSONArray;
import com.jiangjiang.eshop.commodity.dto.GoodsSkuDTO;
import com.jiangjiang.eshop.order.dto.OrderItemDTO;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @ClassName AbstractGiftPromotionActivityCalculator
 * @Description TODO
 * @Author jhw
 * @Date 2021/7/16 11:24
 * @Version 1.0
 **/
public abstract class AbstractGiftPromotionActivityCalculator {

    protected List<OrderItemDTO> createGiftOrderItems(List<GoodsSkuDTO> goodsSkuDTOList) {

        return goodsSkuDTOList.stream().map(goods ->
                OrderItemDTO.builder()
                        .goodsId(goods.getId())
                        .goodsSkuCode(goods.getSkuCode())
                        .goodsName(goods.getGoodsName())
                        .saleProperties(goods.getSaleProperties())
                        .goodsGrossWeight(goods.getGrossWeight())
                        .purchaseQuantity(1L)
                        .purchasePrice(0.0)
                        .promotionActivityId(null)
                        .goodsLength(goods.getGoodsLength())
                        .goodsWidth(goods.getGoodsWidth())
                        .goodsHeight(goods.getGoodsHeight())
                        .build()
        ).collect(Collectors.toList());
    }
}
